package com.situ.day2;

import org.junit.Test;

public class Hello {
    @Test
    public void test1(){
        //byte short(char) int long
        char ch ='a';
        System.out.println(ch);//a
        System.out.println(ch + 1);
        System.out.println(ch + 2);
        System.out.println((char)(ch + 1));
        System.out.println((char)(ch + 2));

        double d = 3.14;
        int num = (int)d;
        System.out.println(num);
    }

    @Test
    public void teat2(){
        //双目运算符
        int num1 = 3;
        int num2 = 5;
        int result = num1 + num2;
        System.out.println(result);
        System.out.println(num1 - num2);
        System.out.println(num1 * num2);
        System.out.println(num1 / num2);

        System.out.println(8 / 2);
        System.out.println(8 % 2);
        System.out.println(8 / 5);
        System.out.println(8 % 5);
    }

    //单目运算符
    //num1++
    @Test
    public void test3(){
        int num = 1;
        num = num + 1;
        System.out.println(num);
        //++(自增1)  --（自减1）
        int i = 1;
        i++;
        System.out.println(i);
        System.out.println(i++);
        System.out.println(i);
        System.out.println(++i);
    }

    //比较运算符
    @Test
    public void  test4(){
        System.out.println(3 >= 5);
        System.out.println(5 < 10);
        System.out.println(5 == 10);
        System.out.println(5 <= 10);
        int num1 = 3;
        int num2 = 5;
        System.out.println(num1 != num2);
        boolean bool1 = num1 != num2;
        System.out.println(bool1);
        boolean bool2 = 3 >= 5;
        System.out.println(bool2);
    }
    //逻辑运算符
    @Test
    public void test5(){
        int score1 = 67;
        int score2 = 256;
        //比较运算符的优先级高于逻辑运算符
        //加了括号之后就不依赖默认优先级：（）>比较运算符>逻辑运算符
        boolean result1 = (score1 >= 60) && (score2 >= 400);
        System.out.println(result1);
        boolean result2 = (score1 >= 60) || (score2 >= 400);
        System.out.println(result2);

        //短路
        int num1 = 3;
        int num2 = 5;
        //&&短路
        System.out.println(num1 < 0 && num1++ < num2);//false
        System.out.println(num1);//3
        System.out.println(num2);//5
    }
}
